package code1;

import java.util.HashMap;
import java.util.HashSet;

/**
 * @author noob
 * @version 1.0
 * @date 2021/3/21 20:23
 *
 * 需要看源码---每个类型的hashCode实现可能不一样
 */
public class Main {
    public static void main(String[] args) {

        int a = 42;
        System.out.println(((Integer) a).hashCode()); //42

        int b = -42;
        System.out.println(((Integer) b).hashCode()); //-42

        double c = 3.1415926;
        System.out.println(((Double) c).hashCode());  //219937201


        String d = "imooc";
        System.out.println(d.hashCode());


        Student student = new Student(3, 2, "junjun", "Zhou");
        System.out.println(student.hashCode());


        HashSet<Student> set = new HashSet<>();
        set.add(student);

        HashMap<Student, Integer> scores = new HashMap<>();
        scores.put(student, 100);

        //对比不重写hashCode，使用java踢提供的
        Student student2 = new Student(3, 2, "junjun", "Zhou");
        System.out.println(student2.hashCode());

    }
}
